package com.example.permissionservice.controller;

import com.example.permissionservice.model.Result;
import com.example.permissionservice.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 功能描述:
 *
 * @author Lenovo
 * @date 2025/6/15
 */
@RestController
@RequestMapping("/permission")
public class PermissionController {
    @Autowired
    private PermissionService permissionService;

    @PostMapping("/bind-default-role")
    public Result<Void> bindDefaultRole(@RequestParam Long userId) {
        return permissionService.bindDefaultRole(userId);
    }

    @GetMapping("/user-role-code")
    public Result<String> getUserRoleCode(@RequestParam Long userId) {
        return permissionService.getUserRoleCode(userId);
    }

    @PostMapping("/upgrade-to-admin")
    public Result<Void> upgradeToAdmin(@RequestParam Long userId) {
        return permissionService.upgradeToAdmin(userId);
    }
    @PostMapping("/downgrade-to-user")
    public Result<Void> downgradeToUser(@RequestParam Long userId) {
        return permissionService.downgradeToUser(userId);
    }
}
